<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace Admin\Model;

use Think\Model\RelationModel;
/**
 * Description of GoodsTypeModel
 *
 * @author Administrator
 */
class GoodsTypeModel extends RelationModel {
    //put your code here
    
    protected  $tableName = 'goods_type';
    
    protected $_auto = array ( 
        array('ctime','time',1,'function')
    );
    
    protected $_link = array(
       
        'goods'=>array(
            'mapping_type' => self::HAS_MANY,
            'class_name' =>'goods',
            'foreign_key'=>'goods_type',
            'parent_key' => 'id',
            'mapping_key' => 'id'
        ),
       
    );
    
    public function getList($where=[],$relation=false,$check=false){
        $where['status'] = 1;
        if($check){
            $this->_link['goods']['mapping_limit'] =  '5';
        }
        return $this->relation($relation)->where($where)->select();
    }
    
    public function getTypeInfoById($id){
        return $this->where("id=".$id)->find();
    }
    
    public function delTypeById($id){
        return $this->where("id=".$id)->delete();
    }
    
    public function getGoodsList(){
        
    }
}
